package com.misyi.designpattern.builder;

/**
 * 没有使用构造器模式
 *
 * @author licong
 * @date 2021-09-11 下午11:26
 */
public class WithoutBuilderPatternDemo {

    public static void main(String[] args) {
        Product product = new Product();
        System.out.println("在设置field1之前进行复杂的校验逻辑");
        product.setField1("值1");
        System.out.println("在设置field2之前进行复杂的数据格式转换逻辑");
        product.setField2("值2");
        System.out.println("在设置field3之前进行复杂的数据处理逻辑, 跟其他对象进行关联");
        product.setField3("值3");
        System.out.println(product);

    }


    public static class Product {
        private String field1;

        private String field2;

        private String field3;

        public String getField1() {
            return field1;
        }

        public void setField1(String field1) {
            this.field1 = field1;
        }

        public String getField2() {
            return field2;
        }

        public void setField2(String field2) {
            this.field2 = field2;
        }

        public String getField3() {
            return field3;
        }

        public void setField3(String field3) {
            this.field3 = field3;
        }


        @Override
        public String toString() {
            return "Product{" +
                    "field1='" + field1 + '\'' +
                    ", field2='" + field2 + '\'' +
                    ", field3='" + field3 + '\'' +
                    '}';
        }
    }

}
